import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            in.nextLine();
            for (int i = 0; i < n; i++) {
                int h = in.nextInt();
                int a = in.nextInt();
                int H = in.nextInt();
                int A = in.nextInt();
                if (a >= H) {
                    System.out.println(-1);
                    continue;
                }
                int ret = 0;
                while (h > 0) {
                    int tmp = H;
                    while (h > 0 && tmp > 0) {
                        tmp -= a;
                        if (tmp <= 0) {
                            ret++;
                            break;
                        }
                        h -= A;
                    }
                }
                System.out.println(ret);
            }
        }
    }
}
